package exception;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FinallyDemo2 {
    public static void main(String[] args) {
        FileOutputStream fos=null;
        try{
            fos=new FileOutputStream("fos.dat");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (Exception e){
            System.out.println("出现IO异常并解决");
        }finally {
            try {
                if(fos!=null) {
                    fos.close();
                }
            } catch (Exception e) {
                System.out.println("关闭流时出现异常并解决了");
            }
        }
        System.out.println("程序结束了");
    }
}
